namespace Microsoft.ServiceModel.Samples.Discovery.Protocol
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.ServiceModel;

    
    [XmlType(Namespace = ProtocolStrings.Namespace)]
    [XmlRoot(ProtocolStrings.ProbeMatchElement,
        Namespace = ProtocolStrings.Namespace)]
    public class ProbeMatch : ServiceProperties
    {
        public static ProbeMatch FromServiceProperties(
            ServiceProperties serviceProperties)
        {
            if (serviceProperties == null)
                throw new ArgumentNullException("serviceProperties");

            ProbeMatch probeMatch = new ProbeMatch();

            probeMatch.EndpointAddress = serviceProperties.EndpointAddress;
            probeMatch.MetadataVersion = serviceProperties.MetadataVersion;
            probeMatch.Types = serviceProperties.Types;
            probeMatch.Scopes = serviceProperties.Scopes;
            probeMatch.XAddrs = serviceProperties.XAddrs;
            probeMatch.AnyElements = serviceProperties.AnyElements;
            probeMatch.AnyAttributes = serviceProperties.AnyAttributes;

            return probeMatch;
        }

        public bool IsValid()
        {
            return (this.EndpointAddress != null);
        }
    }
}
